// pages/record/record.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    BankName: "",
    depositDate: "",
    vecordList: [],
    endDate: '',
    isInquire:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    app.api.request(
      "/BankBaseInfo/GetBankBaseInfo", {},
      "GET",
      res => {
        that.setData({
          BankList: res.data
        })
      },
      res => { }
    );
    app.api.requestFrom(
      "/TradeDetail/TradeDetailInfo", {
        openId: app.globalData.openId
      },
      "GET",
      res => {
        that.setData({
          vecordList: res.data,
          isInquire: true
        })
      },
      res => { }
    );
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  bindPickerChange(e) {
    this.setData({
      index: e.detail.BankId,
      BankName: this.data.BankList[e.detail.value].BankName,
      BankId: this.data.BankList[e.detail.value].BankId
    })
  },
  bindDateChange: function (e) { //存款日期
    this.setData({
      depositDate: e.detail.value
    })
  },
  bindEndDateChange: function (e) { //存款日期
    this.setData({
      endDate: e.detail.value
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  inquire: function () {
    var that = this
    app.api.requestFrom(
      "/TradeDetail/TradeDetailInfo", {
        startDate: that.data.depositDate,
        endDate: that.data.endDate,
        openId: app.globalData.openId,
        BankId: that.data.BankId
      },
      "GET",
      res => {
        that.setData({
          vecordList: res.data,
          isInquire:true
        })
      },
      res => { }
    );
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})